#include <iostream>
using namespace std;



void change(int *a,int i){
	a[i-1] += a[i];
	a[i+1] += a[i];
	a[i] = 0-a[i];
	return;
}

int main(){
	int t;
	cin>>t;
	for(int k=0;k<t;k++){
		int n,a_sum=0,b_sum=0;
		cin>>n;
		int a[n],b[n];
		for(int i=0;i<n;i++){
			cin>>a[i];
			a_sum += a[i];
		}
		for(int i=0;i<n;i++){
			cin>>b[i];
			b_sum += b[i];
		}
		if(a_sum != b_sum){
			cout<<"No"<<endl;
			continue;
		}
		bool can_change;
		for(int i=0;i<n;i++){
			int sum=0;
			can_change = false;
			for(int j=i;j<n;j++){
				sum += a[j];
				if(sum == b[i]){
					can_change = true;
					for(int u=j;u>i;u--)
						change(a,u);
					break;
				}
			}
			if(!can_change)
				break;
		}
		if(!can_change)
			cout<<"No"<<endl;
		else
			cout<<"Yes"<<endl;
	}
	return 0;
}
